<template>
    <div class="sg-button-box">
        <el-button v-for="(item, index) in btnList" :key="index" :type="item.type" @click="clickHandle(item)">{{
            item.label
        }}</el-button>
    </div>
</template>

<script lang="ts" setup name="SGButton">
import type { IButton } from '@/types/button';

const { btnList } = defineProps({
    btnList: {
        type: Array<IButton>,
        default: () => []
    }
});

// type DynamicEmits = {
//     (event: string, payload: any): void
// }

// const emit = defineEmits<DynamicEmits>()

// const clickHandle = (item: IButton) => {
//     emit(item.optionName, item)
// }

const emit = defineEmits<{
    (e: 'click-button', info: IButton): void;
}>();

const clickHandle = (item: IButton) => {
    emit('click-button', item);
};
</script>
